import Vue from 'vue'
import Router from 'vue-router'
import Home from '../pages/home/Home'
// import Search from '../pages/Search'
// import Collect from '../pages/Collect'
// // import Session from '../pages/Session'
// import About from '../pages/About'
// import Content from '../pages/Content.vue'
import * as type from '../store/mutations_type.js'
import store from '../store/index.js'
import User from '../pages/user/personal/User'
import Login from '../pages/user/login/Login'
import Reg from '../pages/user/register/Reg'
import UpdatePass from '../pages/user/resetPassword/ResetPass'
import Feedback from '../pages/user/feedback/feedback'
import About from '../pages/user/About'
import AboutUS from '../pages/user/aboutUs/AboutUS'
import Tool from '../pages/tool/Tool'
// import News from '../pages/news/News'
// import Msg from '../pages/msg/Msg'
// import Meet from '../pages/home/meet/Meet'
// import MeetDetail from '../pages/home/meet/MeetDetail'
// import WorkLog from '../pages/home/workLog/WorkLog'
// import OnlineSign from '../pages/home/onlineSign/OnlineSign'

Vue.use(Router)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  // {
  //   path: '/search',
  //   name: 'search',
  //   component: Search
  // },
  // {
  //   path: '/collect',
  //   name: 'collect',
  //   component: Collect
  // },
  // // {
  // //   path: '/session',
  // //   name: 'session',
  // //   component: Session
  // // },
  {
    path: '/aboutUs',
    name: 'aboutUs',
    component: AboutUS
  },
  // {
  //   path: '/content/:id',
  //   name: 'content',
  //   component: Content
  // },
  {
    path: '/userInfo',
    name: 'userInfo',
    component: User
  },
  {
    path: '/about',
    component: About
  },
  {
    path: '/tool',
    name: 'Tool',
    component: Tool
  },
  // {
  //   path: '/news',
  //   name: 'news',
  //   component: News
  // },
  // {
  //   path: '/Msg',
  //   name: 'Msg',
  //   component: Msg
  // },
  // {
  //   path: '/meet',
  //   name: 'meet',
  //   component: Meet
  // },
  // {
  //   path: '/meet/meetDetailt',
  //   name: 'meetDetailt',
  //   component: MeetDetail
  // },
  // {
  //   path: '/meet/addMeet',
  //   name: 'addMeet',
  //   component: MeetDetail
  // },
  // {
  //   path: '/workLog',
  //   name: 'workLog',
  //   component: WorkLog
  // },
  // {
  //   path: '/onlineSign',
  //   name: 'onlineSign',
  //   component: OnlineSign
  // },

  {
    path: '/feedback',
    name: 'feedback',
    component: Feedback
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/reg',
    name: 'reg',
    component: Reg
  }, {
    path: '/editPass',
    name: 'editPass',
    component: UpdatePass
  },
  {
    path: '*',
    redirect: '/home'
  }
]

const router = new Router({
  routes
})

// 滚动条控制的部分
router.afterEach((to, from) => {
  store.commit(type.SAVE_POSITION, {
    name: from.path,
    position: document.body.scrollTop || document.documentElement.scrollTop
  })
  if (store.state.positions[to.path]) {
    setTimeout(() => {
      window.scrollTo(0, store.state.positions[to.path])
    }, 80)
  } else {
    setTimeout(() => {
      window.scrollTo(0, 0)
    }, 80)
  }
})
export default router
